<template>
    <div class="wy-main business-car-manage">
     <a-row class="wy-main-title">
       <a-col :span="24">
        <p class="title-p">
          <a-divider class="title-vertical"  type="vertical" />
          <span class="title-span" >管理我的仓储</span>
          <a-divider class="title-divider"  />
        </p>
      </a-col>
   </a-row>
     <div class="my-main-cont">
       <a-form layout="inline">
        <!-- 
          <a-form-item label="栏目">
            <a-select showSearch v-model="contentType"  style="min-width:174px" placeholder="全部">
              <a-select-option key="1" value="全部">全部</a-select-option>
              <a-select-option key="2" value="1">国际新闻</a-select-option>
              <a-select-option key="3" value="2" >国内新闻</a-select-option>
              <a-select-option key="4" value="3" >省内新闻</a-select-option>
              <a-select-option key="5" value="4" >行业焦点</a-select-option>
            </a-select>
          </a-form-item> -->
          <!-- <a-form-item label="审核状态">
            <a-select showSearch v-model="approvalStatus" style="min-width:174px" placeholder="全部">
             <a-select-option key="2" value="全部" >全部</a-select-option>
              <a-select-option key="2" value="106" >待审核</a-select-option>
              <a-select-option key="3" value="107" >审核通过</a-select-option>
              <a-select-option key="4" value="108" >审核不通过</a-select-option>
            </a-select>
          </a-form-item> -->
        <!-- <a-form-item  label="" style="width:200px">
          <a-input v-model="contentTxt"  placeholder='请输入标题（50字以内）' maxlength='50'  />
        </a-form-item> -->
        <a-form-item  label="" style="float:left; width:200px">
          <a-input v-model="contentTxt"  placeholder='请输入仓储名称'   />
        </a-form-item>
        <a-button  type="primary" style="margin-left: 10px; " @click="gettenderinginfo">查询</a-button>
        <a-button  style="margin-left: 14px; " @click="react">重置</a-button>
         <router-link to="/business/network/publish">
         <a-button class="title-button" type="primary" style="float: right;min-width:80px;">新增</a-button>
         </router-link>
      </a-form>

         <div class="wei_new_list">
         <a-table :columns="columns" :rowKey="record => record.contentId" :dataSource="data" :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" :pagination="pagination" :loading="loading" style="margin-top: 20px" >
           <span slot="name" slot-scope="text1">
             <span>{{text1.address1}}--→{{text1.address2}}</span>
           </span>
           <!-- <span slot="attestationStatus" slot-scope="text, record">
             <span v-if="record.attestationStatus==0">未认证</span>
             <span v-if="record.attestationStatus==1">认证中</span>
             <span v-if="record.attestationStatus==2">已认证</span>
           </span>
            <span slot="bidResult" slot-scope="text, record">
             <span v-if="record.bidResult==0">未中标</span>
             <span v-if="record.bidResult==1">中标</span>
           </span> -->
            <span slot="contentType" slot-scope="text, record">
                <span v-if="record.contentType==1">国际新闻</span>
                <span v-if="record.contentType==2">国内新闻</span>
                <span v-if="record.contentType==3">省内新闻</span>
                <span v-if="record.contentType==4">行业焦点</span>
             </span>
<!--              <span slot="vipp" slot-scope="text, record">
                <span v-if="record.vipp==1">普通会员</span>
                <span v-if="record.vipp==2">物流云会员</span>
             </span> -->
             <span slot="approvalStatus" slot-scope="text, record">
                <span v-if="record.approvalStatus==106">待审核</span>
                <span v-if="record.approvalStatus==107">审核通过</span>
                <span v-if="record.approvalStatus==108">审核不通过</span>
             </span>
             <span slot="operation" slot-scope="text, record">
                <a href="javascript:;" @click="seeInfo(record,'add')">查看</a>
                <a href="javascript:;" @click="seeInfo(record,'edit')">修改</a>
                <a href="javascript:;" @click="delNews(record)">删除</a>
             </span>
         </a-table>
         </div>
          <div style="margin-top: -50px">
            <!-- <a-button>选择全部</a-button>
            <a-button>反向选择</a-button>
            <a-button>清除选择</a-button> -->
            <a-button @click="delAll">删除所选</a-button>
          </div>

        <a-modal
        :title="type=='edit'?'修改':'查看'"
        :visible="visible"
        @cancel="handleCancel"
        width="900px"
        :footer="null" class='send-new-model'>
        <div class="business-circuit">
            <manage-info v-if="visible" :isSee="isSee" :type="type" :detail="detail" @handleCancel="handleCancel"></manage-info>
        </div>
      </a-modal>
     </div>
     
    </div>
</template>
<script>
import manageInfo  from './Publish'
const columns = [{
    title: '仓储名称',
    dataIndex: 'contentType',
    key: 'contentType',
     scopedSlots: {
      customRender: 'contentType'
    },
  
  },{
    title: '仓储类型',
    dataIndex: 'type',
    key: 'type'

  },{
    title: '仓储面积',
    dataIndex: 'contentTitle',
    key: 'contentTitle',
  }, 
  // {
  //   title: '浏览权限',
  //   dataIndex: 'vipp',
  //   key: 'vipp'
  // },
  {
    title: '出租价格',
    key: 'looksNum',
    dataIndex: 'looksNum',
  },{
    title: '仓储地址',
    key: 'looksNu',
    dataIndex: 'looksNum',
  },{
    title: '审核状态',
    key: 'approvalStatus',
    dataIndex: 'approvalStatus',
      scopedSlots: {
      customRender: 'approvalStatus'
    },
  },{
    title: '发布时间',
    key: 'createTime',
    dataIndex: 'createTime',
  }, {
      title: '操作',
      key: 'operation',
      scopedSlots: {
        customRender: 'operation'
      },
    }];
// const rowSelection = {
//   onChange: (selectedRowKeys, selectedRows) => {
//     console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
// //   },
// //   onSelect: (record, selected, selectedRows) => {
// //     console.log(record, selected, selectedRows);
// //   },
// //   onSelectAll: (selected, selectedRows, changeRows) => {
// //     console.log(selected, selectedRows, changeRows);
//   },
// };
export default {
    
    data() {
        return {
         datail: {},
         datailAll:{},
         contentType:'全部',
         approvalStatus:'全部',
         contentCode:1,
         contentTxt:'',
         data:[],
         visible: false,
         visibleAll:false,
         loading: false,
         type:'',
         columns,
         // rowSelection,
          selectedRowKeys: [],
          pagination: {
          ageSizeOptions: ['10', '20', '30', '40', '100'],
          defaultCurrent: 1,
          defaultPageSize: 10,
          showSizeChanger: true,
          total:0,
          showTotal: (total, range) => `共 ${total} 条记录 `
        },
        }
    }, 
    created() {
      this.gettenderinginfo()
    },
    components:{
      manageInfo
    },
    methods: {
      // 审核线路信息
      seeInfo(data,type){
        this.visible = true
        this.detail = data
        if(type == 'add'){
          this.isSee = true
           this.type = 'add'
        }else{
          this.isSee = false
          this.type = 'edit'
        }
      },

      //关闭弹框

      handleCancel(){
      this.visible = false
      this.gettenderinginfo();
      this.selectedRowKeys=[];
      },
      //删除
      delAll() {
        this.$confirm({
          title: '确定删除所选中的记录？',
          content: '当您点击确定按钮后，这些记录将会被彻底删除',
          centered: true
        })
      },
      onSelectChange (selectedRowKeys) {
          console.log('selectedRowKeys changed: ', selectedRowKeys);
          this.selectedRowKeys = selectedRowKeys
        },
      //审核
            // 删除单条信息
      delNews(data){
        console.log(data)
        let that = this
        this.$confirm({
          title: '确定删除所选中的记录?',
          content: '当您点击确定按钮后，这些记录将会被彻底删除',
          centered: true,
          onOk () {
            let logIds = []
            logIds.push(data.contentId)
            console.log()
            that.$delete('/content/content/' + logIds.join(',')).then(() => {
              that.$message.success('删除成功')
              that.selectedRowKeys = []
              that.gettenderinginfo()
            })
          },
          onCancel () {
            that.selectedRowKeys = []
          }
        })
      },
    
      //重置
      react() {
        this.defaultCurrent = 1
        this.contentType = '全部'
        this.approvalStatus = '全部'
        this.contentTxt = ''
    

        this.gettenderinginfo()
      },
      // 获取招标信息
      gettenderinginfo(params={}){
        this.loading = true
        if(this.contentType!='全部'){
            params.contentType = this.contentType
        }
        if(this.approvalStatus!='全部'){
          params.approvalStatus = this.approvalStatus
        }
        params.contentTxt = this.contentTxt
        params.contentCode = this.contentCode
        params.pageSize = this.pagination.defaultPageSize
        params.pageNum = this.pagination.defaultCurrent
        this.$get('/content/content', params).then((r) => {
          this.loading = false
          console.log(r)
          this.data = r.data.data.rows
          this.pagination.total = r.data.data.total
        })
      },

    }
}
</script>
<style lang="less">
.wei_new_list .ant-table-body .ant-table-thead tr th:nth-child(3) {
    width: 12%;
    }
</style>